package com.sophialex.health.record.views;

import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DateTime;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormText;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
import org.eclipse.ui.part.ViewPart;

import com.sophialex.health.system.frame.resource.SWTResourceManager;
public class PersonVisitsView extends ViewPart {

	public static final String ID = "com.sophialex.health.record.views.PersonVisitsView"; //$NON-NLS-1$
	private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
	private Text text;
	private Text text_1;
	private Text text_2;
	private Text text_3;
	private Text text_4;
	private Text text_5;
	private Text text_6;
	private Text text_7;
	private Text text_8;
	private Text text_9;
	private Text text_10;
	private Text text_11;
	private Text text_12;
	private Table table;
	private Table table_1;
	private Composite search_1;
	private Table table_2;
	private TableViewer tableViewer;
	private Button button;
	private DateTime dateTime;
	private DateTime dateTime2;
	private DateTime dateTime3;

	public PersonVisitsView() {
	}

	/**
	 * Create contents of the view part.
	 * @param parent
	 */
	@Override
public void createPartControl(Composite parent) {
		
		//parent.setLayout(new FillLayout());
		parent.setLayout(new FillLayout(SWT.FILL));
	
			
//			toolkit.paintBordersFor(m);
//			scrolledComposite.setContent(m);
//			scrolledComposite.setMinSize(m.computeSize(SWT.DEFAULT, SWT.DEFAULT));
//		m.setLayout(new FillLayout(SWT.HORIZONTAL));
		Section section = toolkit.createSection(parent, Section.TITLE_BAR);
		section.setFont(SWTResourceManager.getFont("宋体", 14, SWT.BOLD));

		toolkit.paintBordersFor(section);
		section.setText("就诊信息                     ");
		section.setExpanded(true);

		ScrolledComposite scrolledComposite = new ScrolledComposite(section,  SWT.H_SCROLL | SWT.V_SCROLL);
		toolkit.adapt(scrolledComposite);
		//toolkit.paintBordersFor(scrolledComposite);
		scrolledComposite.setExpandHorizontal(true);
		scrolledComposite.setExpandVertical(true);
		Composite m = toolkit.createComposite(scrolledComposite, SWT.NONE);
		
		Composite container = new Composite(scrolledComposite, SWT.NONE);
		container.setLayout(new FormLayout());
		FormData fd_label = new FormData();
		fd_label.top = new FormAttachment(0, 0);
		fd_label.left = new FormAttachment(0, 0);

		section.setClient(scrolledComposite);

		
		
		Section section_1 = toolkit.createSection(container, Section.TWISTIE
				| Section.TITLE_BAR);
		FormData fd_section_1 = new FormData();
		fd_section_1.top = new FormAttachment(0);
		fd_section_1.left = new FormAttachment(0, 0);
		fd_section_1.right = new FormAttachment(100, 0);
		section_1.setLayoutData(fd_section_1);
		toolkit.paintBordersFor(section_1);
		section_1.setText("就诊记录");
		section_1.setExpanded(true);

		Composite composite_1 = toolkit.createComposite(section_1, SWT.NONE);
		toolkit.paintBordersFor(composite_1);
		section_1.setClient(composite_1);

		TableWrapLayout twl_composite_1 = new TableWrapLayout();
		twl_composite_1.verticalSpacing = 10;
		twl_composite_1.horizontalSpacing = 10;
		twl_composite_1.numColumns = 6;
		composite_1.setLayout(twl_composite_1);

		{
			Label label = toolkit.createLabel(composite_1, "接诊日期", SWT.NONE);
			label.setLayoutData(new TableWrapData(TableWrapData.RIGHT,
					TableWrapData.TOP, 1, 1));
		}

		{
			dateTime3 = new DateTime(composite_1, SWT.BORDER | SWT.DROP_DOWN);
			dateTime3.setLayoutData(new TableWrapData(TableWrapData.LEFT,
					TableWrapData.TOP, 1, 5));
			toolkit.adapt(dateTime3);
			toolkit.paintBordersFor(dateTime3);
		}
		{
			FormText formText = toolkit.createFormText(composite_1, false);
			toolkit.paintBordersFor(formText);
			formText.setText(
					"\u4E3B\u8BC9\u548C\u536B\u751F\u670D\u52A1\u8981\u6C42",
					false, false);
		}

		{
			text = toolkit.createText(composite_1, "", SWT.WRAP | SWT.MULTI);
			// twd_text.heightHint = 40;
			TableWrapData twd_text = new TableWrapData(TableWrapData.FILL_GRAB,
					TableWrapData.FILL, 1, 2);
			twd_text.heightHint = 50;
			text.setLayoutData(twd_text);
		}
		{
			Label label = toolkit.createLabel(composite_1, "体格检查结果", SWT.NONE);
			label.setLayoutData(new TableWrapData(TableWrapData.RIGHT,
					TableWrapData.TOP, 1, 1));
		}

		{
			text_1 = toolkit.createText(composite_1, "", SWT.WRAP | SWT.MULTI);
			// twd_text_1.heightHint = 52;
			text_1.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB,
					TableWrapData.FILL, 1, 2));
		}
		{
			Label label = toolkit.createLabel(composite_1, "实验室检查结果", SWT.NONE);
			label.setLayoutData(new TableWrapData(TableWrapData.RIGHT,
					TableWrapData.TOP, 1, 1));
		}

		{
			text_2 = toolkit.createText(composite_1, "", SWT.WRAP | SWT.MULTI);
			// twd_text_2.heightHint = 91;
			TableWrapData twd_text_2 = new TableWrapData(TableWrapData.FILL_GRAB,
					TableWrapData.FILL, 1, 2);
			twd_text_2.heightHint = 50;
			text_2.setLayoutData(twd_text_2);
		}
		{
			Label label = toolkit.createLabel(composite_1, "辅助检查等结果", SWT.NONE);
			label.setLayoutData(new TableWrapData(TableWrapData.RIGHT,
					TableWrapData.TOP, 1, 1));
		}
		{
			text_3 = toolkit.createText(composite_1, "", SWT.WRAP | SWT.MULTI);
			// twd_text_3.heightHint = 55;
			text_3.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB,
					TableWrapData.FILL, 1, 2));
		}
		{
			Label label = toolkit.createLabel(composite_1, "健康问题判断", SWT.NONE);
			label.setLayoutData(new TableWrapData(TableWrapData.RIGHT,
					TableWrapData.TOP, 1, 1));
		}
		{
			text_4 = toolkit.createText(composite_1, "", SWT.WRAP | SWT.MULTI);
			// twd_text_4.heightHint = 78;
			TableWrapData twd_text_4 = new TableWrapData(TableWrapData.FILL_GRAB,
					TableWrapData.FILL, 1, 5);
			twd_text_4.heightHint = 50;
			text_4.setLayoutData(twd_text_4);
		}

		Section section_2 = toolkit.createSection(container, Section.TWISTIE
				| Section.TITLE_BAR);

		section_2.setText("计划");
		section_2.setExpanded(true);
		FormData fd_section_2 = new FormData();
		fd_section_2.top = new FormAttachment(section_1, 0);
		fd_section_2.left = new FormAttachment(0, 0);
		fd_section_2.right = new FormAttachment(100, -0);
		section_2.setLayoutData(fd_section_2);
		toolkit.paintBordersFor(section_2);
		toolkit.paintBordersFor(section_2);
		Composite composite_2 = toolkit.createComposite(section_2, SWT.NONE);
		toolkit.paintBordersFor(composite_2);
		section_2.setClient(composite_2);

		{
			TableWrapLayout twl_composite_2 = new TableWrapLayout();
			twl_composite_2.leftMargin = 10;
			twl_composite_2.verticalSpacing = 10;
			twl_composite_2.numColumns = 6;
			composite_2.setLayout(twl_composite_2);
		}
		{
			Label label = toolkit.createLabel(composite_2, "       诊断",
					SWT.NONE);
			label.setLayoutData(new TableWrapData(TableWrapData.RIGHT,
					TableWrapData.TOP, 1, 2));
		}
		{
			text_8 = toolkit.createText(composite_2, "", SWT.WRAP);
			// twd_text_8.heightHint = 46;
			TableWrapData twd_text_8 = new TableWrapData(TableWrapData.FILL_GRAB,
					TableWrapData.TOP, 1, 1);
			twd_text_8.heightHint = 50;
			text_8.setLayoutData(twd_text_8);
		}

		{
			Label label = toolkit.createLabel(composite_2, "治疗", SWT.NONE);
			label.setLayoutData(new TableWrapData(TableWrapData.RIGHT,
					TableWrapData.TOP, 1, 2));
		}
		{
			text_9 = toolkit.createText(composite_2, "", SWT.WRAP);
			// twd_text_9.heightHint = 42;
			text_9.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB,
					TableWrapData.FILL, 1, 1));
		}

		{
			Label label = toolkit.createLabel(composite_2, "健康指导", SWT.NONE);
			label.setLayoutData(new TableWrapData(TableWrapData.RIGHT,
					TableWrapData.TOP, 1, 2));
		}
		{
			text_10 = toolkit.createText(composite_2, "", SWT.WRAP);
			// twd_text_10.heightHint = 46;
			TableWrapData twd_text_10 = new TableWrapData(TableWrapData.FILL_GRAB,
					TableWrapData.TOP, 1, 4);
			twd_text_10.heightHint = 50;
			text_10.setLayoutData(twd_text_10);
		}

		Section section_3 = toolkit.createSection(container, Section.TWISTIE
				| Section.TITLE_BAR);
		FormData fd_section_3 = new FormData();
		fd_section_3.top = new FormAttachment(section_2, 0);
		fd_section_3.left = new FormAttachment(section_1, 0, SWT.LEFT);
		fd_section_3.right = new FormAttachment(100, 0);
		fd_section_3.bottom = new FormAttachment(100, 0);
		section_3.setLayoutData(fd_section_3);
		toolkit.paintBordersFor(section_3);
		section_3.setText("就诊信息查询");
		
		Composite composite_3 = toolkit.createComposite(section_3, SWT.NONE);
		toolkit.paintBordersFor(composite_3);
		section_3.setClient(composite_3);
		section_3.setExpanded(true);
		composite_3.setLayout(new FormLayout());
		
		
		Composite comp_search = toolkit.createComposite(composite_3, SWT.NONE);
		{
			TableWrapLayout twl_comp_search = new TableWrapLayout();
			twl_comp_search.makeColumnsEqualWidth = true;
			twl_comp_search.numColumns = 5;
			comp_search.setLayout(twl_comp_search);
		}
		FormData fd_comp_search = new FormData();
		fd_comp_search.right = new FormAttachment(100);
		fd_comp_search.top = new FormAttachment(0);
		fd_comp_search.left = new FormAttachment(0);
		comp_search.setLayoutData(fd_comp_search);
		toolkit.paintBordersFor(comp_search);
		
		
		{
			Label label = toolkit.createLabel(comp_search, "              从", SWT.NONE);
			label.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.MIDDLE, 1, 1));
		}
		{
			dateTime2 = new DateTime(comp_search, SWT.BORDER | SWT.DROP_DOWN);
			dateTime2.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
			toolkit.adapt(dateTime2);
			toolkit.paintBordersFor(dateTime2);
		}
		{
			Label label = toolkit.createLabel(comp_search, "        到", SWT.NONE);
			label.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.MIDDLE, 1, 1));
		}
		{
			dateTime = new DateTime(comp_search, SWT.BORDER | SWT.DROP_DOWN);
			dateTime.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
			toolkit.adapt(dateTime);
			toolkit.paintBordersFor(dateTime);
		}
		{
			button = toolkit.createButton(comp_search, "查找(&S)", SWT.NONE);
			TableWrapData twd_button = new TableWrapData(TableWrapData.RIGHT, TableWrapData.MIDDLE, 1, 1);
			twd_button.grabHorizontal = true;
			button.setLayoutData(twd_button);
		}
		
		Composite tc = toolkit.createComposite(composite_3, SWT.V_SCROLL);
		tc.setLayout(new FillLayout());
		FormData fd_tc = new FormData();
		fd_tc.right = new FormAttachment(comp_search, 0, SWT.RIGHT);
		fd_tc.top = new FormAttachment(comp_search, 2);
		fd_tc.left = new FormAttachment(0,0);
		fd_tc.bottom = new FormAttachment(100,-10);
		tc.setLayoutData(fd_tc);
		
		tableViewer = new TableViewer(tc, SWT.BORDER | SWT.FULL_SELECTION);
		table_2 = tableViewer.getTable();
		
		initTable(table_2);
		
		scrolledComposite.setContent(container);
		scrolledComposite.setMinSize(container.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		createActions();
		initializeToolBar();
		initializeMenu();
	}

	private void initTable(Table table) {
		table.setLinesVisible(true);
        table.setHeaderVisible(true);
       // table.setBounds(97, 79, 373, 154);

        final TableColumn newColumnTableColumn = new TableColumn(table, SWT.NONE);
        newColumnTableColumn.setWidth(39);
        newColumnTableColumn.setText("列1");

        final TableColumn newColumnTableColumn_1 = new TableColumn(table, SWT.NONE);
        newColumnTableColumn_1.setWidth(85);
        newColumnTableColumn_1.setText("列2");
        
        final TableColumn newColumnTableColumn_2 = new TableColumn(table, SWT.NONE);
        newColumnTableColumn_2.setWidth(41);
        newColumnTableColumn_2.setText("列3");

        final TableColumn newColumnTableColumn_3 = new TableColumn(table, SWT.NONE);
        newColumnTableColumn_3.setWidth(43);
        newColumnTableColumn_3.setText("列3");

        final TableColumn newColumnTableColumn_4 = new TableColumn(table, SWT.NONE);
        newColumnTableColumn_4.setWidth(126);
        newColumnTableColumn_4.setText("列4");
		
	}

	public void dispose() {
		toolkit.dispose();
		super.dispose();
	}

	/**
	 * Create the actions.
	 */
	private void createActions() {
		// Create the actions
	}

	/**
	 * Initialize the toolbar.
	 */
	private void initializeToolBar() {
		IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager();
	}

	/**
	 * Initialize the menu.
	 */
	private void initializeMenu() {
		IMenuManager manager = getViewSite().getActionBars().getMenuManager();
	}

	@Override
	public void setFocus() {
		// Set the focus
	}
}

